package com.komodo.island.gdx.dialog;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.actors.Button;
import com.komodo.island.gdx.GameDescription;
import com.komodo.island.gdx.Input;
import com.komodo.island.gdx.KomodoIsland;
import com.komodo.island.gdx.Persistence;
import com.komodo.island.gdx.screen.MapScreen;
import com.komodo.island.gdx.screen.Screen;

public class MapScientistDialog extends MapDialog {

	Button buttonBalance;
	Button buttonSuit;
	Button buttonMove;
	Button buttonPhoto;

	GameDescription description;

	public MapScientistDialog(float width, float height, boolean stretch,
			Screen screen, Texture texture,KomodoIsland komodoIsland) {
		super(width, height, stretch, screen, texture,komodoIsland);
		// TODO Auto-generated constructor stub
		this.ID = Input.DIALOG_SCIENTIST_MAP;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		super.init();
		buttonBalance = new Button("balance", new TextureRegion(
				komodoIsland.buttonTexture, 480, 100 + 64 + 30, 95, 28));
		buttonMove = new Button("move", new TextureRegion(
				komodoIsland.buttonTexture, 480, 100 + 64, 60, 29));
		buttonPhoto = new Button("photo", new TextureRegion(
				komodoIsland.buttonTexture, 90, 200, 63, 45));
		buttonSuit = new Button("suit", new TextureRegion(
				komodoIsland.buttonTexture, 480 + 100, 0, 102, 65));
		// description = new GameDescription("desc");

		// play = new Button("play", new TextureRegion(texture, 0, 0, 50, 50));
		// help = new Button("help", new TextureRegion(texture, 0, 0, 50, 50));

	}

	@Override
	public void addElements() {
		// TODO Auto-generated method stub
		super.addElements();
		if (Persistence.levelUnlocked[Persistence.BALANCE])
			addActor(buttonBalance);
		if (Persistence.levelUnlocked[Persistence.PHOTO])
			addActor(buttonPhoto);
		if (Persistence.levelUnlocked[Persistence.MOVE])
			addActor(buttonMove);
		if (Persistence.levelUnlocked[Persistence.SUIT])
			addActor(buttonSuit);

		// description.addActor(play);
		// description.addActor(help);
		//
		// play.x = 0;
		// play.y = 0;
		//
		// help.x = 50;
		// help.y = 0;

	}

	@Override
	public void setThePosition() {
		// TODO Auto-generated method stub
		super.setThePosition();
		buttonBalance.x = 283;
		buttonBalance.y = 214;

		buttonMove.x = 354;
		buttonMove.y = 70;

		buttonSuit.x = 390;
		buttonSuit.y = 197;

		buttonPhoto.x = 256;
		buttonPhoto.y = 69;

		// description.x = 480 - 200;
		// description.y = 0;
	}

	@Override
	public void setTheListener() {
		// TODO Auto-generated method stub
		super.setTheListener();
		buttonSuit.clickListener = new Button.ClickListener() {

			public void clicked(Button arg0) {
				// TODO Auto-generated method stub

				// komodoIsland.scientistScreen.chosenGame =
				// MapScreen.SUIT;
				//
				// komodoIsland.gameSuit.startGame();
				// komodoIsland.goToScreen(komodoIsland.gameSuit);
				if (Persistence.sound)
					komodoIsland.mapSound.play(1);
				((MapScreen) screen).showGameDesc(MapScreen.SUIT);

			}
		};
		buttonBalance.clickListener = new Button.ClickListener() {

			public void clicked(Button arg0) {
				// TODO Auto-generated method stub
				// komodoIsland.scientistScreen.chosenGame =
				// MapScreen.BALANCE;
				//
				// komodoIsland.gameBalance.startGame();
				// komodoIsland.goToScreen(komodoIsland.gameBalance);
				if (Persistence.sound)
					komodoIsland.mapSound.play(1);
				((MapScreen) screen).showGameDesc(MapScreen.BALANCE);

			}
		};
		buttonPhoto.clickListener = new Button.ClickListener() {

			public void clicked(Button arg0) {
				// TODO Auto-generated method stub
				// komodoIsland.scientistScreen.chosenGame =
				// MapScreen.PHOTO;

				// komodoIsland.gameKomodoPhoto.startGame();
				// screen.komodoIsland
				// .goToScreen(komodoIsland.gameKomodoPhoto);
				//
				if (Persistence.sound)
					komodoIsland.mapSound.play(1);
				((MapScreen) screen).showGameDesc(MapScreen.PHOTO);

			}
		};
		buttonMove.clickListener = new Button.ClickListener() {

			public void clicked(Button arg0) {
				// TODO Auto-generated method stub
				if (Persistence.sound)
					komodoIsland.mapSound.play(1);
				((MapScreen) screen).showGameDesc(MapScreen.MOVE);

				// komodoIsland.gameKomodoMove.startGame();
				// screen.komodoIsland
				// .goToScreen(komodoIsland.gameKomodoMove);
				// addActor(description);
			}
		};

	}

	@Override
	public boolean touchUp(int x, int y, int pointer, int button) {
		// TODO Auto-generated method stub
		// if (hit(x, y) == null) {
		// // removeActor(description);
		// }
		return super.touchUp(x, y, pointer, button);
	}

}
